<?
	//session_start();
?>
<script type="text/javascript">
	function hapus(Cat,ID)
	{
		var ok = confirm("Apakah Anda yakin menghapus data tersebut ?");
		if(ok == true)
		{
			window.location.href="delete.php?cat="+ Cat +"&id="+ ID +"";
		}
		else
		{
		}
	}
</script>

<?
// list of function
//include("config.php");

// show data
/*function ShowData($conn,$sql,$cat){
	$result 	= mssql_query($sql,$conn);
	$sumField	= mssql_num_fields($result);
	while($row 	= mssql_fetch_array($result)){
	echo"<tr>";
		for($i=0;$i<$sumField;$i++){
			echo"<td valign='top' class=contentlist><a href='rep_cv.php?nik=$row[NIK]' target='_blank'>$row[$i]</a></td>";
		}
	
	if($cat == "employee"){
		$form	= "../form/frm_emp.php?op=edit&amp;nik=$row[NIK]";
	}

	echo"<td><a href='$form'><img src='../images/b_edit.png' title='Edit' alt='Edit' border=0></a><a href='delete.php'><img src='../images/b_delete.png' title='Delete' alt='Delete' border='0'></td>";
	echo"</tr>";
	
	}
}*/

function ShowData($conn,$sql,$cat){
	$result 	= mssql_query($sql,$conn);
	$sumField	= mssql_num_fields($result);
	while($row 	= mssql_fetch_array($result)){
	echo"<tr>";
		for($i=0;$i<$sumField;$i++){
			echo"<td valign='top' class=contentlist><a href='detailemp.php?show=data_umum&amp;nik=$row[NIK]'>$row[$i]</a></td>";
		}
	
	if($cat == "employee"){
		$form	= "../form/frm_emp.php?op=edit&amp;nik=$row[NIK]";
	}
	echo"</tr>";
	
	}
}


function ShowData2($conn,$sql,$cat){
	$result 	= mssql_query($sql,$conn);
	$sumField	= mssql_num_fields($result);
	while($row 	= mssql_fetch_array($result)){
	echo"<tr>";
		for($i=0;$i<$sumField;$i++){
			echo"<td valign='top' class=contentlist><a href='rep_cv.php?nik=$row[NIK]' target='_blank'>$row[$i]</a></td>";
		}
	
	/*if($cat == "employee"){
		$form	= "../form/frm_emp.php?op=edit&amp;nik=$row[NIK]";
	}
	*/
	echo"</tr>";
	
	}
}


function ShowDataList($conn,$sql,$cat){
	$result 	= mssql_query($sql,$conn);
	$sumField	= mssql_num_fields($result);
	while($row 	= mssql_fetch_array($result)){
	echo"<tr>";
		for($i=0;$i<$sumField;$i++){
			echo"<td valign='top' class=contentlist>$row[$i]</td>";
		}
			echo"
			<td>
			<input type='hidden' name='nik' value='".$row[0]."'><input type='hidden' value='".$row[1]."' name='nama' readonly>
			<input type=button value=&radic;>
			</td>
			";
	}
	echo"</tr>";
}

// input data
function InsertData($conn,$sql,$cat){
	$result 	= mssql_query($sql,$conn);
	
	if($cat == "insert"){
		//include("../header.php");
		$msg_yes	= "
			<br><br>
			Data sudah disimpan ...
			<br><br>
			[ <a href='Javascript:history.go(-2);'>kembali</a> ]
		";
		$msg_no		= "
			<div align=center style='color: red;'>
			<br><br>
			Data gagal disimpan ...
			<br><br>
			[ <a href='Javascript:history.go(-1);'>kembali</a> ]
			</div>
		";
	}
	elseif($cat == "update"){
		//include("../header.php");
		$msg_yes	= "
			<br><br>
			Data sudah diupdate ...
			<br><br>
			[ <a href='Javascript:history.go(-2);'>kembali</a> ]
		";
		$msg_no		= "
			<div align=center style='color: red;'>
			<br><br>
			Data gagal diupdate ...
			<br><br>
			[ <a href='Javascript:history.go(-1);'>kembali</a> ]
			</div>
		";
	}
	elseif($cat == "delete"){
		//include("../header.php");
		$msg_yes	= "
			<br><br>
			Data sudah dihapus ...
			<br><br>
			[ <a href='Javascript:history.go(-1);'>kembali</a> ]
		";
		$msg_no		= "
			<div align=center style='color: red;'>
			<br><br>
			Data gagal dihapus ...
			<br><br>
			[ <a href='Javascript:history.go(-1);'>kembali</a> ]
			</div>
		";
	}
	
	if($result){
		echo"
		 <table align=center width=100%>
		  <tr>
		   <td align=center>$msg_yes .</td>
		  </tr>
		 </table>
		";
	}
	else{
		echo"
		 <table align=center width=100%>
		  <tr>
		   <td align=center>$msg_no</td>
		  </tr>
		 </table>
		";
	}
}

// insert data employee
function InsertDataEmp($conn,$sql,$cat,$nik){
	//exit($sql);
	$result = mssql_query($sql,$conn);
	
	if($cat == "insert"){
		/*
		$msg_yes	= "
		<table style='width: 100%; height: 100%;'>
		 <tr>
		    <td align=center valign=midle>
		   	Data sudah disimpan, Apakah Anda akan memasukkan data-data dibawah ini: <br><br>
			[ <a href='../form/frm_emp_pendidikan.php?nik=$nik'>Pendidikan</a> | Kursus | Keluarga | Karir | Organisasi ]
		    </td>
		 </tr>
		</table>
		";
		*/
		$msg_yes	= "
		<table style='width: 100%; height: 100%;'>
		 <tr>
		    <td align=center valign=midle>
		   	Data sudah disimpan, untuk memasukkan data detail pegawai silahkan pergunakan menu MASTER KARYAWAN.
		    </td>
		 </tr>
		</table>
		";
		$msg_no		= "
		<table style='width: 100%; height: 100%;'>
		 <tr>
		  <td style='width: 100%; height: 100%; color: red; font-size: 11px; text-align: center;'>
		Data Not Saved ...
		  </td>
		 </tr>
		</table>
		";
	}
	elseif($cat == "update"){
		//$msg_yes	= "Data Updated ...";
		//$msg_no		= "Data Not Updated ...";
		$msg_yes	= "
			<br><br>
			Data sudah diupdate ...
			<br><br>
			[ <a href='Javascript:history.go(-2);'>kembali</a> ]
		";
		$msg_no		= "
			<div align=center style='color: red;'>
			<br><br>
			Data gagal diupdate ...
			<br><br>
			[ <a href='Javascript:history.go(-1);'>kembali</a> ]
			</div>
		";

	}
	elseif($cat == "delete"){
//		$msg_yes	= "Data Deleted ...";
//		$msg_no		= "Data Not Deleted ...";
		$msg_yes	= "
			<br><br>
			Data sudah dihapus ...
			<br><br>
			[ <a href='Javascript:history.go(-2);'>kembali</a> ]
		";
		$msg_no		= "
			<div align=center style='color: red;'>
			<br><br>
			Data gagal dihapus ...
			<br><br>
			[ <a href='Javascript:history.go(-1);'>kembali</a> ]
			</div>
		";

	}
	
	if($result){
		echo"
		 <table align=center width=100% border=0>
		  <tr>
		   <td colspan='2'>";
			//include("../header.php");   
		echo"</td>
		  </tr>
		  <tr>
		   <td width=10%>";
		echo"</td>
		    <td align=center valign=midle align=center >
		   	$msg_yes
		    </td>
		   </tr>";
		echo"
		   <tr>
		    <td colspan=2>"; 
			include("../footer.php");   
		echo"</td>
		    </tr>
		   </table>
		";
	}
	else{
		echo"
		 <table align=center width=100%>
		  <tr>
		   <td colspan='2'>";
			//include("../header.php");   
		echo"</td>
		  </tr>
		  <tr>
		   <td align=center>$msg_no.</td>
		  </tr>
		 </table>
		";
	}
}
// Class untuk Paging
class Pager
{
   function getPagerData($numHits, $limit, $page)
   {
	   $numHits  = (int) $numHits;
	   $limit    = max((int) $limit, 1);
	   $page     = (int) $page;
	   $numPages = ceil($numHits / $limit);

	   $page 	= max($page, 1);
	   $page 	= min($page, $numPages);

	   $offset 	= ($page - 1) * $limit;

	   $ret 	= new stdClass;

	   $ret->offset   = $offset;
	   $ret->limit    = $limit;
	   $ret->numPages = $numPages;
	   $ret->page     = $page;

	   return $ret;
   }
}

?>